3.49 \(\int \frac{\cot ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx\)

Optimal. Leaf size=141 \[ -\frac{3 (3 A+i B) \cot (c+d x)}{4 a^2 d}-\frac{(-B+2 i A) \log (\sin (c+d x))}{a^2 d}+\frac{(2 A+i B) \cot (c+d x)}{2 a^2 d (1+i \tan (c+d x))}-\frac{3 x (3 A+i B)}{4 a^2}+\frac{(A+i B) \cot (c+d x)}{4 d (a+i a \tan (c+d x))^2} \]

[Out]

(-3*(3*A + I*B)*x)/(4*a^2) - (3*(3*A + I*B)*Cot[c + d*x])/(4*a^2*d) - (((2*I)*A - B)*Log[Sin[c + d*x]])/(a^2*d
) + ((2*A + I*B)*Cot[c + d*x])/(2*a^2*d*(1 + I*Tan[c + d*x])) + ((A + I*B)*Cot[c + d*x])/(4*d*(a + I*a*Tan[c +
 d*x])^2)

________________________________________________________________________________________

Rubi [A]  time = 0.345708, antiderivative size = 141, normalized size of antiderivative = 1., number of steps used = 5, number of rules used = 4, integrand size = 34, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.118, Rules used = {3596, 3529, 3531, 3475} \[ -\frac{3 (3 A+i B) \cot (c+d x)}{4 a^2 d}-\frac{(-B+2 i A) \log (\sin (c+d x))}{a^2 d}+\frac{(2 A+i B) \cot (c+d x)}{2 a^2 d (1+i \tan (c+d x))}-\frac{3 x (3 A+i B)}{4 a^2}+\frac{(A+i B) \cot (c+d x)}{4 d (a+i a \tan (c+d x))^2} \]

Antiderivative was successfully verified.

[In]

Int[(Cot[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x])^2,x]

[Out]

(-3*(3*A + I*B)*x)/(4*a^2) - (3*(3*A + I*B)*Cot[c + d*x])/(4*a^2*d) - (((2*I)*A - B)*Log[Sin[c + d*x]])/(a^2*d
) + ((2*A + I*B)*Cot[c + d*x])/(2*a^2*d*(1 + I*Tan[c + d*x])) + ((A + I*B)*Cot[c + d*x])/(4*d*(a + I*a*Tan[c +
 d*x])^2)

Rule 3596

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[((a*A + b*B)*(a + b*Tan[e + f*x])^m*(c + d*Tan[e + f*x])^(n + 1))/(2
*f*m*(b*c - a*d)), x] + Dist[1/(2*a*m*(b*c - a*d)), Int[(a + b*Tan[e + f*x])^(m + 1)*(c + d*Tan[e + f*x])^n*Si
mp[A*(b*c*m - a*d*(2*m + n + 1)) + B*(a*c*m - b*d*(n + 1)) + d*(A*b - a*B)*(m + n + 1)*Tan[e + f*x], x], x], x
] /; FreeQ[{a, b, c, d, e, f, A, B, n}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] && LtQ[m, 0] &&  !GtQ[n,
0]

Rule 3529

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[((
b*c - a*d)*(a + b*Tan[e + f*x])^(m + 1))/(f*(m + 1)*(a^2 + b^2)), x] + Dist[1/(a^2 + b^2), Int[(a + b*Tan[e +
f*x])^(m + 1)*Simp[a*c + b*d - (b*c - a*d)*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c
 - a*d, 0] && NeQ[a^2 + b^2, 0] && LtQ[m, -1]

Rule 3531

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[((a*c +
 b*d)*x)/(a^2 + b^2), x] + Dist[(b*c - a*d)/(a^2 + b^2), Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x]
 /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[a*c + b*d, 0]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int \frac{\cot ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx &=\frac{(A+i B) \cot (c+d x)}{4 d (a+i a \tan (c+d x))^2}+\frac{\int \frac{\cot ^2(c+d x) (a (5 A+i B)-3 a (i A-B) \tan (c+d x))}{a+i a \tan (c+d x)} \, dx}{4 a^2}\\ &=\frac{(2 A+i B) \cot (c+d x)}{2 a^2 d (1+i \tan (c+d x))}+\frac{(A+i B) \cot (c+d x)}{4 d (a+i a \tan (c+d x))^2}+\frac{\int \cot ^2(c+d x) \left (6 a^2 (3 A+i B)-8 a^2 (2 i A-B) \tan (c+d x)\right ) \, dx}{8 a^4}\\ &=-\frac{3 (3 A+i B) \cot (c+d x)}{4 a^2 d}+\frac{(2 A+i B) \cot (c+d x)}{2 a^2 d (1+i \tan (c+d x))}+\frac{(A+i B) \cot (c+d x)}{4 d (a+i a \tan (c+d x))^2}+\frac{\int \cot (c+d x) \left (-8 a^2 (2 i A-B)-6 a^2 (3 A+i B) \tan (c+d x)\right ) \, dx}{8 a^4}\\ &=-\frac{3 (3 A+i B) x}{4 a^2}-\frac{3 (3 A+i B) \cot (c+d x)}{4 a^2 d}+\frac{(2 A+i B) \cot (c+d x)}{2 a^2 d (1+i \tan (c+d x))}+\frac{(A+i B) \cot (c+d x)}{4 d (a+i a \tan (c+d x))^2}-\frac{(2 i A-B) \int \cot (c+d x) \, dx}{a^2}\\ &=-\frac{3 (3 A+i B) x}{4 a^2}-\frac{3 (3 A+i B) \cot (c+d x)}{4 a^2 d}-\frac{(2 i A-B) \log (\sin (c+d x))}{a^2 d}+\frac{(2 A+i B) \cot (c+d x)}{2 a^2 d (1+i \tan (c+d x))}+\frac{(A+i B) \cot (c+d x)}{4 d (a+i a \tan (c+d x))^2}\\ \end{align*}

Mathematica [B]  time = 6.03195, size = 302, normalized size = 2.14 \[ \frac{\sec (c+d x) (\cos (d x)+i \sin (d x))^2 (A+B \tan (c+d x)) \left (\frac{1}{4} (B-i A) (\cos (2 c)-i \sin (2 c)) \cos (4 d x)+4 d x (2 A+i B) (\cos (2 c)+i \sin (2 c))-3 d x (3 A+i B) (\cos (2 c)+i \sin (2 c))-\frac{1}{4} (A+i B) (\cos (2 c)-i \sin (2 c)) \sin (4 d x)+2 (B-2 i A) (\cos (2 c)+i \sin (2 c)) \log \left (\sin ^2(c+d x)\right )-4 (2 A+i B) (\cos (2 c)+i \sin (2 c)) \tan ^{-1}(\tan (d x))-(3 A+2 i B) \sin (2 d x)+(2 B-3 i A) \cos (2 d x)+4 A \csc (c) (\cos (2 c)+i \sin (2 c)) \sin (d x) \csc (c+d x)\right )}{4 d (a+i a \tan (c+d x))^2 (A \cos (c+d x)+B \sin (c+d x))} \]

Antiderivative was successfully verified.

[In]

Integrate[(Cot[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x])^2,x]

[Out]

(Sec[c + d*x]*(Cos[d*x] + I*Sin[d*x])^2*(((-3*I)*A + 2*B)*Cos[2*d*x] + (((-I)*A + B)*Cos[4*d*x]*(Cos[2*c] - I*
Sin[2*c]))/4 + 4*(2*A + I*B)*d*x*(Cos[2*c] + I*Sin[2*c]) - 3*(3*A + I*B)*d*x*(Cos[2*c] + I*Sin[2*c]) - 4*(2*A
+ I*B)*ArcTan[Tan[d*x]]*(Cos[2*c] + I*Sin[2*c]) + 2*((-2*I)*A + B)*Log[Sin[c + d*x]^2]*(Cos[2*c] + I*Sin[2*c])
 + 4*A*Csc[c]*Csc[c + d*x]*(Cos[2*c] + I*Sin[2*c])*Sin[d*x] - (3*A + (2*I)*B)*Sin[2*d*x] - ((A + I*B)*(Cos[2*c
] - I*Sin[2*c])*Sin[4*d*x])/4)*(A + B*Tan[c + d*x]))/(4*d*(A*Cos[c + d*x] + B*Sin[c + d*x])*(a + I*a*Tan[c + d
*x])^2)

________________________________________________________________________________________

Maple [A]  time = 0.102, size = 211, normalized size = 1.5 \begin{align*} -{\frac{5\,A}{4\,{a}^{2}d \left ( \tan \left ( dx+c \right ) -i \right ) }}-{\frac{{\frac{3\,i}{4}}B}{{a}^{2}d \left ( \tan \left ( dx+c \right ) -i \right ) }}-{\frac{7\,\ln \left ( \tan \left ( dx+c \right ) -i \right ) B}{8\,{a}^{2}d}}+{\frac{{\frac{17\,i}{8}}\ln \left ( \tan \left ( dx+c \right ) -i \right ) A}{{a}^{2}d}}+{\frac{{\frac{i}{4}}A}{{a}^{2}d \left ( \tan \left ( dx+c \right ) -i \right ) ^{2}}}-{\frac{B}{4\,{a}^{2}d \left ( \tan \left ( dx+c \right ) -i \right ) ^{2}}}-{\frac{B\ln \left ( \tan \left ( dx+c \right ) +i \right ) }{8\,{a}^{2}d}}-{\frac{{\frac{i}{8}}A\ln \left ( \tan \left ( dx+c \right ) +i \right ) }{{a}^{2}d}}-{\frac{A}{{a}^{2}d\tan \left ( dx+c \right ) }}-{\frac{2\,iA\ln \left ( \tan \left ( dx+c \right ) \right ) }{{a}^{2}d}}+{\frac{B\ln \left ( \tan \left ( dx+c \right ) \right ) }{{a}^{2}d}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(cot(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x)

[Out]

-5/4/d/a^2/(tan(d*x+c)-I)*A-3/4*I/d/a^2/(tan(d*x+c)-I)*B-7/8/d/a^2*ln(tan(d*x+c)-I)*B+17/8*I/d/a^2*ln(tan(d*x+
c)-I)*A+1/4*I/d/a^2/(tan(d*x+c)-I)^2*A-1/4/d/a^2/(tan(d*x+c)-I)^2*B-1/8/d/a^2*B*ln(tan(d*x+c)+I)-1/8*I/d/a^2*A
*ln(tan(d*x+c)+I)-1/d/a^2*A/tan(d*x+c)-2*I/d/a^2*A*ln(tan(d*x+c))+1/d/a^2*B*ln(tan(d*x+c))

________________________________________________________________________________________

Maxima [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: RuntimeError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cot(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

Exception raised: RuntimeError

________________________________________________________________________________________

Fricas [A]  time = 1.43534, size = 433, normalized size = 3.07 \begin{align*} -\frac{4 \,{\left (17 \, A + 7 i \, B\right )} d x e^{\left (6 i \, d x + 6 i \, c\right )} -{\left (4 \,{\left (17 \, A + 7 i \, B\right )} d x - 44 i \, A + 8 \, B\right )} e^{\left (4 i \, d x + 4 i \, c\right )} -{\left (11 i \, A - 7 \, B\right )} e^{\left (2 i \, d x + 2 i \, c\right )} -{\left ({\left (-32 i \, A + 16 \, B\right )} e^{\left (6 i \, d x + 6 i \, c\right )} +{\left (32 i \, A - 16 \, B\right )} e^{\left (4 i \, d x + 4 i \, c\right )}\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} - 1\right ) - i \, A + B}{16 \,{\left (a^{2} d e^{\left (6 i \, d x + 6 i \, c\right )} - a^{2} d e^{\left (4 i \, d x + 4 i \, c\right )}\right )}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cot(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

-1/16*(4*(17*A + 7*I*B)*d*x*e^(6*I*d*x + 6*I*c) - (4*(17*A + 7*I*B)*d*x - 44*I*A + 8*B)*e^(4*I*d*x + 4*I*c) -
(11*I*A - 7*B)*e^(2*I*d*x + 2*I*c) - ((-32*I*A + 16*B)*e^(6*I*d*x + 6*I*c) + (32*I*A - 16*B)*e^(4*I*d*x + 4*I*
c))*log(e^(2*I*d*x + 2*I*c) - 1) - I*A + B)/(a^2*d*e^(6*I*d*x + 6*I*c) - a^2*d*e^(4*I*d*x + 4*I*c))

________________________________________________________________________________________

Sympy [A]  time = 14.7981, size = 223, normalized size = 1.58 \begin{align*} - \frac{2 i A e^{- 2 i c}}{a^{2} d \left (e^{2 i d x} - e^{- 2 i c}\right )} - \frac{\left (\begin{cases} 17 A x e^{4 i c} + \frac{3 i A e^{2 i c} e^{- 2 i d x}}{d} + \frac{i A e^{- 4 i d x}}{4 d} + 7 i B x e^{4 i c} - \frac{2 B e^{2 i c} e^{- 2 i d x}}{d} - \frac{B e^{- 4 i d x}}{4 d} & \text{for}\: d \neq 0 \\x \left (17 A e^{4 i c} + 6 A e^{2 i c} + A + 7 i B e^{4 i c} + 4 i B e^{2 i c} + i B\right ) & \text{otherwise} \end{cases}\right ) e^{- 4 i c}}{4 a^{2}} + \frac{\left (- 2 i A + B\right ) \log{\left (e^{2 i d x} - e^{- 2 i c} \right )}}{a^{2} d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cot(d*x+c)**2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))**2,x)

[Out]

-2*I*A*exp(-2*I*c)/(a**2*d*(exp(2*I*d*x) - exp(-2*I*c))) - Piecewise((17*A*x*exp(4*I*c) + 3*I*A*exp(2*I*c)*exp
(-2*I*d*x)/d + I*A*exp(-4*I*d*x)/(4*d) + 7*I*B*x*exp(4*I*c) - 2*B*exp(2*I*c)*exp(-2*I*d*x)/d - B*exp(-4*I*d*x)
/(4*d), Ne(d, 0)), (x*(17*A*exp(4*I*c) + 6*A*exp(2*I*c) + A + 7*I*B*exp(4*I*c) + 4*I*B*exp(2*I*c) + I*B), True
))*exp(-4*I*c)/(4*a**2) + (-2*I*A + B)*log(exp(2*I*d*x) - exp(-2*I*c))/(a**2*d)

________________________________________________________________________________________

Giac [A]  time = 1.31596, size = 219, normalized size = 1.55 \begin{align*} \frac{\frac{2 \,{\left (-i \, A - B\right )} \log \left (\tan \left (d x + c\right ) + i\right )}{a^{2}} - \frac{2 \,{\left (-17 i \, A + 7 \, B\right )} \log \left (\tan \left (d x + c\right ) - i\right )}{a^{2}} - \frac{16 \,{\left (2 i \, A - B\right )} \log \left ({\left | \tan \left (d x + c\right ) \right |}\right )}{a^{2}} - \frac{16 \,{\left (-2 i \, A \tan \left (d x + c\right ) + B \tan \left (d x + c\right ) + A\right )}}{a^{2} \tan \left (d x + c\right )} - \frac{51 i \, A \tan \left (d x + c\right )^{2} - 21 \, B \tan \left (d x + c\right )^{2} + 122 \, A \tan \left (d x + c\right ) + 54 i \, B \tan \left (d x + c\right ) - 75 i \, A + 37 \, B}{a^{2}{\left (\tan \left (d x + c\right ) - i\right )}^{2}}}{16 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cot(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x, algorithm="giac")

[Out]

1/16*(2*(-I*A - B)*log(tan(d*x + c) + I)/a^2 - 2*(-17*I*A + 7*B)*log(tan(d*x + c) - I)/a^2 - 16*(2*I*A - B)*lo
g(abs(tan(d*x + c)))/a^2 - 16*(-2*I*A*tan(d*x + c) + B*tan(d*x + c) + A)/(a^2*tan(d*x + c)) - (51*I*A*tan(d*x
+ c)^2 - 21*B*tan(d*x + c)^2 + 122*A*tan(d*x + c) + 54*I*B*tan(d*x + c) - 75*I*A + 37*B)/(a^2*(tan(d*x + c) -
I)^2))/d